
import javax.swing.*;
import java.awt.*;
import java.util.Scanner;


public class program_7_1 {


    private JFrame frame;
    private JPanel leftPanel;
    private int[] polygonX = new int[] {0, 10, 10, 20, 20, 30, 30, 0};
    private int[] polygonY = new int[] {0, 0, 10, 10, 0, 0, 20, 20};
  //private int[] polygon = new int[] {0, 0, 10, 0, 10, 10, 20, 10, 20, 0, 30, 0, 30, 20, 0, 20};

    program_7_1(String[] args) {
    	
    	Scanner in = new Scanner(System.in);
        System.out.println("Введите смещение по X");
        int x = in.nextInt();
        System.out.println("Введите смещение по Y");
        int y = in.nextInt();
        System.out.println("Введите коаффицент увелечения N");
        int n = in.nextInt();
        in.close();
        
        for (int i = 0; i+1 <= polygonX.length; i++) {
        	polygonX[i] = polygonX[i] * n + x;
        }
        for (int i = 0; i+1 <= polygonY.length; i++) {
        	polygonY[i] = polygonY[i] * n + y;
        }
        
        
        if (n == 0 && x>=0 && x<=500 && y>=0 && y<=500) {
        } else if (n > 0 && x>=0 && y>=0 && 30 * n + x<=500 && 20 * n +y<=500) {
        } else if (n < 0 && 30 * n + x>=0 && 20 * n +y>=0 && x<=500 && y<=500) {
        } else {
        	System.out.println("Размер фигуры превышает максимальный размер поля");
        	System.exit(0);
        }
       
        
   
        frame = new JFrame("ИТ марафон");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setPreferredSize(new Dimension(500, 500));
        frame.setLocationByPlatform(true);


        leftPanel = new JPanel(){
            @Override
            public Dimension getPreferredSize() {
                return new Dimension(500, 500);
            }

            @Override
            protected void paintComponent(Graphics graphics) {
                super.paintComponent(graphics);
                Insets ins = getInsets();
                graphics.fillPolygon(polygonX, polygonY, 8);                
                
            }

        };

        frame.add(leftPanel, BorderLayout.CENTER);
        
    }

    
    public void show() {
       	frame.pack();
    	frame.setVisible(true);
    }

    public static void main(final String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {       
                new program_7_1(args).show();     
            }
        });
    }
}